from django.shortcuts import render
from django.contrib.auth.models import User


def user_reg(request):
    if request.method == 'GET':
        return render(request, '6/user_reg.html')
    if request.method == "POST":
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        if User.objects.filter(username=username):
            info = "用户已经存在"
        else:
            # d = dict(username=username, password=password, email="lixiuhu_lee@123.com", is_active=1, is_superuser=1)
            # user = User.objects.create_user(**d)
            info = "注册成功，请登录"
        return render(request, '6/user_reg.html', {"info": info})
